// 获取推荐歌单

// const express = require('express');
// const app = express();
const Http = require('../util/request');

module.exports = (query, request) => {
    console.log(query.cookies, query.proxy)
    return Http(
        'GET', `https://music.163.com`, {},
        {cookie: query.cookies, proxy: query.proxy}
    )
    .then(response => {
        try{
            let profile = eval(`(${/GUser\s*=\s*([^;]+);/.exec(response.body)[1]})`)
            let bindings = eval(`(${/GBinds\s*=\s*([^;]+);/.exec(response.body)[1]})`)
            response.body = {code: 200, profile: profile, bindings: bindings}
            // return response
            request.json(response)
        }
        catch(err){
            response.status = 301
            response.body = {code: 301}
            request.json(response)
            // return Promise.reject(response)
        }
    }).catch( err => {
        request.json(err)
    })
};
